﻿<!DOCTYPE html>
<html>
<head>
	<script src="//code.jquery.com/jquery-3.6.4.js" type="text/javascript"></script>
	<script src="../../jsrender.js" type="text/javascript"></script>
	<link href="../resources/demos.css" rel="stylesheet" type="text/css" />

	<link href="../resources/movielist.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a href="../demos.html">JsRender Demos</a><br />

<h3>Using {{for}} to render hierarchical data - inline nested template.</h3>

<script id="movieTemplate" type="text/x-jsrender">
	<tr>
		<td>{{>title}}</td>
		<td>
			{{for languages}}
				<div class="{{:#index%2 ? 'even' : 'odd'}}"></div>
				<div>
					<em>{{>name}}</em>
				</div>
			{{else}}
				No alternate languages
			{{/for}}
		</td>
	</tr>
</script>

<table>
	<thead><tr><th>Title</th><th>Languages</th></tr></thead>
	<tbody id="movieList"></tbody>
</table>

<script type="text/javascript">

	var movies = [
		{
			title: "Meet Joe Black",
			languages: [
				{ name: "English" },
				{ name: "French" }
			]
		},
		{
			title: "Eyes Wide Shut",
			languages: [
				{ name: "French" },
				{ name: "Mandarin" },
				{ name: "Spanish" }
			]
		},
		{
			title: "The Inheritance",
			languages: [
				{ name: "English" },
				{ name: "German" }
			]
		},
		{
			title: "Local Story",
			languages: []
		},
		{
			title: "My Home Video"
		}
	];

	$( "#movieList" ).html(
		$( "#movieTemplate" ).render( movies )
	);

</script>

</body>
</html>


